package com.hz.userService.controller;

import com.hz.apiService.model.domain.StudentDTO;
import com.hz.apiService.model.request.ApiResponse;
import com.hz.userService.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor  // 使用构造器自动注入
public class StudentController {
    @Resource
    UserService userService;

    @GetMapping("/student-info")
    public String studentInfo(@RequestParam("studentId") Integer studentId){
        StudentDTO studentDTO = userService.getStudentById(studentId);
        return studentDTO == null ? ApiResponse.resNotFound() : ApiResponse.ok(studentDTO);
    }

}
